package radioButton;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.BoxLayout;

import java.awt.Color;

import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JSeparator;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;

public class TestJRadioButton extends JFrame {

	private JPanel contentPane;
	/**
	 * @wbp.nonvisual location=72,69
	 */
	private final ButtonGroup buttonGroup = new ButtonGroup();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TestJRadioButton frame = new TestJRadioButton();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TestJRadioButton() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
		
		JPanel superior = new JPanel();
		superior.setBackground(UIManager.getColor("InternalFrame.activeTitleGradient"));
		contentPane.add(superior);
		
		Object[][] datos = {
				{"1", "Java", "PUE"},
				{"2", ".NET", "CIFO"}
		};
		
		String[] nomCols = {"ID", "Materia", "Centro"};
		
		JTable tabla = new JTable(datos, nomCols);
		tabla.setBounds(10, 350, 300, 300);
		superior.add(tabla);
		
		JRadioButton rdbtnHombre = new JRadioButton("Hombre");
		superior.add(rdbtnHombre);
		
		JRadioButton rdbtnMujer = new JRadioButton("Mujer");
		superior.add(rdbtnMujer);
		
		JRadioButton rdbtnOtro = new JRadioButton("Otro");
		superior.add(rdbtnOtro);
		
		buttonGroup.add(rdbtnMujer);
		buttonGroup.add(rdbtnHombre);
		buttonGroup.add(rdbtnOtro);
		
		JComboBox preferencias = new JComboBox();
		preferencias.setModel(new DefaultComboBoxModel(new String[] {"Seleccione...", "Cerveza", "Cola", "Vino", "Agua"}));
		superior.add(preferencias);
				
		JPanel inferior = new JPanel();
		inferior.setBackground(UIManager.getColor("InternalFrame.activeTitleGradient"));
		contentPane.add(inferior);
		
		JButton btnSiguiente = new JButton("Siguiente >>");
		btnSiguiente.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String pref = (String) preferencias.getSelectedItem();
				if (pref.equals("Seleccione...")) {
					System.out.println("No ha seleccionado nada");
				} else {
					System.out.println(pref);
				}
			}
		});
		
		JScrollPane scrollPane = new JScrollPane(tabla);
		superior.add(scrollPane);
		inferior.add(btnSiguiente);
	}

}
